package cn.sdormitory.classHygiene.dao;

import cn.sdormitory.classHygiene.entity.AppClassHygiene;
import cn.sdormitory.classHygiene.entity.ClassHygieneItem;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @className: AppClassHygieneDao
 * @author: Alex
 * @date: 2024/12/12
 **/
@Mapper
public interface AppClassHygieneDao extends BaseMapper<AppClassHygiene> {
	@Select("SELECT * FROM class_hygiene WHERE id = #{classHygieneId} AND DATE_FORMAT(check_date, '%Y-%m-%d') = #{checkDate}")
	@Results({
			@Result(property = "items", column = "id",
					many = @Many(select = "selectHygieneItemsByHygieneId"))
	})
	AppClassHygiene selectClassHygieneWithItems(Long classHygieneId, String checkDate);
	
	@Select("SELECT * FROM class_hygiene_item WHERE class_hygiene_id = #{classHygieneId}")
	List<ClassHygieneItem> selectHygieneItemsByHygieneId(Long classHygieneId);
}
